import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Search from '../views/search/Search.vue'
import HighSearch from '../views/HighSearch.vue'
import SearchResult from '../views/SearchResult.vue'

const contentSerach = () => import(/* webpackChunkName: "search" */'@/views/search/contentSearch.vue');
const project = () => import(/* webpackChunkName: "project" */'@/views/projectCenter/list.vue');
const content = () => import(/* webpackChunkName: "content" */'@/views/projectCenter/content.vue');

// 这样导入有按需加载
const PersonCenter = () => import(/* webpackChunkName: "person-center" */'@/views/personCenter/layout.vue');
const Account = () => import(/* webpackChunkName: "account" */'@/views/personCenter/account');
const ServiceHall = () => import('@/views/personCenter/serviceHall');
const BiddingCustomized = () => import('@/views/personCenter/biddingCustomized');
const WxOfficial = () => import(/* webpackChunkName: "safe" */'@/views/personCenter/wxOfficial');
const SafeMail = () => import(/* webpackChunkName: "safe" */'@/views/personCenter/safeMail');
const SafeTel = () => import(/* webpackChunkName: "safe" */'@/views/personCenter/safeTel');
const SendMail = () => import(/* webpackChunkName: "send-mail" */'@/views/personCenter/sendMail');
const ApplyInvoice = () => import(/* webpackChunkName: "invoice" */'@/views/personCenter/invoice/apply');
const HistoryInvoice = () => import(/* webpackChunkName: "invoice" */'@/views/personCenter/invoice/history');
const SupplyInfoRelease = () => import(/* webpackChunkName: "supply" */'@/views/personCenter/supplyInfo/release');
const SupplyInfoList = () => import(/* webpackChunkName: "supply" */'@/views/personCenter/supplyInfo/list');
const DemandInfoRelease = () => import(/* webpackChunkName: "demand" */'@/views/personCenter/demandInfo/release');
const DemandInfoList = () => import(/* webpackChunkName: "demand" */'@/views/personCenter/demandInfo/list');


const Collection = () => import(/* webpackChunkName: "projectCollection" */'@/views/personCenter/collection');
const myTentder = () => import(/* webpackChunkName: "tentder" */'@/views/personCenter/tentder/purchasingAgent.vue');

Vue.use(VueRouter)

export const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/search',
    name: 'Search',
    component: Search
  },
  {
    path: '/highsearch',
    name: 'HighSearch',
    component: HighSearch
  },
  {
    path: '/searchresult',
    name: 'SearchResult',
    component: contentSerach
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/project',
    name: 'Project',
    meta: {
      title: '项目列表'
    },
    component: project
  },
  {
    path: '/content/:id',
    name: 'content',
    meta: {
      name: '内容详情'
    },
    component: content
  },
  {
    path: '/personCenter',
    name: 'PersonCenter',
    component: PersonCenter,

    children: [
      {
        path: 'service_hall',
        name: 'ServiceHall',
        meta: {
          title: "服务大厅",
        },
        component: ServiceHall
      },
      {
        path: 'bidding_customized',
        name: 'BiddingCustomized',
        meta: {
          title: "招标定制",
        },
        component: BiddingCustomized
      },
      {
        path: 'account',
        name: 'Account',
        meta: {
          title: "账号管理",
        },
        component: Account
      },
      {
        path: 'wx_official',
        name: 'WxOfficial',
        meta: {
          title: "公众号服务",
        },
        component: WxOfficial
      },
      {
        path: 'safe_mail',
        name: 'SafeMail',
        meta: {
          title: "安全邮箱",
        },
        component: SafeMail
      },
      {
        path: 'safe_tel',
        name: 'SafeTel',
        meta: {
          title: "安全手机",
        },
        component: SafeTel
      },
      {
        path: 'send_mail',
        name: 'SendMail',
        meta: {
          title: "邮箱提醒管理",
        },
        component: SendMail
      },
      {
        path: 'invoice_apy/:apy?',
        name: 'ApplyInvoice',
        meta: {
          title: "申请发票",
          active_path: '/personCenter/invoice_apy',
        },
        component: ApplyInvoice
      },
      {
        path: 'invoice_his',
        name: 'HistoryInvoice',
        meta: {
          title: "历史发票",
        },
        component: HistoryInvoice
      },
      {
        path: 'supply_rel',
        name: 'SupplyInfoRelease',
        meta: {
          title: "供应信息发布",
        },
        component: SupplyInfoRelease
      },
      {
        path: 'supplys',
        name: 'SupplyInfoList',
        meta: {
          title: "供应信息列表",
        },
        component: SupplyInfoList
      },
      {
        path: 'demand_rel',
        name: 'DemandInfoRelease',
        meta: {
          title: "需求信息发布",
        },
        component: DemandInfoRelease
      },
      {
        path: 'demands',
        name: 'DemandInfoList',
        meta: {
          title: "需求信息发布",
        },
        component: DemandInfoList
      },
      {
        path: 'collection',
        name: 'Collection',
        meta: {
          title: "项目收藏",
        },
        component: Collection
      },
      {
        path: 'tentder',
        name: 'myTentder',
        meta: {
          title: "我的代购",
        },
        component: myTentder
      }

    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
